package com.junlong0716.enjoylearning.ui

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.RelativeLayout
import com.blankj.utilcode.util.ToastUtils
import com.junlong0716.enjoylearning.R
import com.junlong0716.module.common.base.BaseFragment

/**
 *@author: 巴黎没有摩天轮Li
 *@description:
 *@date: Created in 下午8:53 2018/4/22
 *@modified by:
 */
class PublishFragment : BaseFragment<PublishPresenter>(), PublishContract.View, View.OnClickListener {
    override fun attachPresenter() {
        mPresenter = PublishPresenter()
        mPresenter!!.attachView(this)
    }

    override fun getLayoutId(): Int = R.layout.fragment_publish

    override fun initViews(mRootView: View?) {
        initView(mRootView)
    }

    private fun initView(mRootView: View?) {
        mRootView!!.findViewById<RelativeLayout>(R.id.rl_search).setOnClickListener(this)
        mRootView.findViewById<RelativeLayout>(R.id.rl_publish_audio).setOnClickListener(this)
        mRootView.findViewById<RelativeLayout>(R.id.rl_publish_video).setOnClickListener(this)
        mRootView.findViewById<RelativeLayout>(R.id.rl_public_document).setOnClickListener(this)
        mRootView.findViewById<RelativeLayout>(R.id.rl_publish_special).setOnClickListener(this)

    }

    override fun lazyFetchData() {

    }

    override fun onClick(v: View?) {
        when (v!!.id) {
            R.id.rl_search -> {
                go(SearchActivity::class.java)
            }
            R.id.rl_publish_audio -> {
                val bundle = Bundle()
                bundle.putInt("UPLOAD_TYPE", 2)
                go(UploadAudioActivity::class.java, bundle)
            }
            R.id.rl_public_document -> {
                val bundle = Bundle()
                bundle.putInt("UPLOAD_TYPE", 3)
                go(UploadAudioActivity::class.java, bundle)
            }
            R.id.rl_publish_video -> {
                val bundle = Bundle()
                bundle.putInt("UPLOAD_TYPE", 1)
                go(UploadAudioActivity::class.java, bundle)
            }
            R.id.rl_publish_special -> {
                ToastUtils.showShort("手机端不支持专题文件上传！请前往享学管理系统上传！")
            }
            else -> {
            }
        }
    }

}